package com.technology.education.ui.student.search

import androidx.lifecycle.MutableLiveData
import com.technology.education.data.model.SearchModel
import com.technology.education.ext.toast
import com.technology.education.network.apiService
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.ext.request
import me.hgj.jetpackmvvm.state.ResultState

class SearchViewModel : BaseViewModel() {
    var searchKey = ""
    val result = MutableLiveData<ResultState<SearchModel>>()
    val history= setOf<String>()

    override fun getData() {
        super.getData()
        if (searchKey.isEmpty()){
            toast("请输入要搜索的内容")
            return
        }
        history.plus(searchKey)
        request({ apiService.search(hashMapOf("keyword" to searchKey)) }, result)
    }
}